package com.api.server.service.impl;

import com.api.server.pojo.Equipment;
import com.api.server.mapper.EquipmentMapper;
import com.api.server.service.IEquipmentService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author shi
 * @since 2022-04-28
 */
@Service
public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment> implements IEquipmentService {

    @Autowired
    EquipmentMapper equipmentMapper;

    @Override
    public Equipment message(String equipmentnumber) {

        return equipmentMapper.selectById(equipmentnumber);
    }

    @Override
    public int add(Equipment equipment) {
        equipment.setEquipmentisfree("是");
        equipment.setEquipmentisnormal("是");
        return equipmentMapper.insert(equipment);
    }

    @Override
    public int delete(String id) {
        return equipmentMapper.deleteById(id);
    }

    @Override
    public List<Equipment> equByCdId(String id) {
        return equipmentMapper.selectList(new QueryWrapper<Equipment>().lambda().eq(Equipment::getEquipmentfield,id));
    }

    @Override
    public int updataById(Equipment equipment) {
        return equipmentMapper.updateById(equipment);
    }
}
